import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        int[] array = {12,56,89,78,10,5,3,7,6};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
}
    public static void bubbleSort(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            boolean flg = false;
            for (int j = 0; j < array.length-1-i; j++) {
                if(array[j] > array[j+1]){
                    int tmp = 0;
                    tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flg = true;
                }
            }
            if(flg == false){
                return;
            }
        }
    }
}
